﻿// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.TransformCryptoSession
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 8E14765A-6610-409A-BA36-099A0642905D
// Assembly location: E:\git\ALLIDA\windll\infocard.exe

using System;
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography;
using System.Security.Principal;

namespace Microsoft.InfoCards
{
  internal class TransformCryptoSession : CryptoSession
  {
    private ICryptoTransform m_icrypto;

    public TransformCryptoSession(
      Process process,
      DateTime expiration,
      WindowsIdentity identity,
      ICryptoTransform icrypto)
      : base(process, expiration, identity, (object) icrypto, CryptoSession.SessionType.Transfrom)
    {
      this.m_icrypto = icrypto;
    }

    protected override void OnDispose()
    {
      this.m_icrypto.Dispose();
    }

    protected override void OnWrite(BinaryWriter bwriter)
    {
      bwriter.Write(this.m_icrypto.InputBlockSize);
      bwriter.Write(this.m_icrypto.OutputBlockSize);
      bwriter.Write(this.m_icrypto.CanTransformMultipleBlocks);
      bwriter.Write(this.m_icrypto.CanReuseTransform);
    }

    public int TransformBlock(byte[] inData, out byte[] outData)
    {
      outData = new byte[this.m_icrypto.OutputBlockSize];
      return this.m_icrypto.TransformBlock(inData, 0, inData.Length, outData, 0);
    }

    public byte[] TransformFinalBlock(byte[] inData)
    {
      return this.m_icrypto.TransformFinalBlock(inData, 0, inData.Length);
    }
  }
}
